#==============================================================================
# ■ Window_Command
#
#     与Window_Command功能一致,不同点就是可以自己给定行、列的值，使菜单像轩辕剑
# 系列的排列……
#
# 举例：                            行  列               -命令列表-
#      Window_Command.new(160, ["攻击","法术","物品","绝技","防御","逃跑"],2)
#==============================================================================
#==============================================================================
# ■ Window_Command
#------------------------------------------------------------------------------
# 　一般的命令选择行窗口。
#==============================================================================

class Window_Command < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     width    : 每格的的宽
  #     row      : 行数   自己根据命令数算好行列的值
  #     column   : 列数
  #     commands : 命令字符串序列
  #     type     : 光标类型
  #--------------------------------------------------------------------------
  def initialize(width,commands,column=1,type=0,align=1,index=0,x=0,y=0,h=480)
    row = commands.size / column
    maxh = h
    # 由命令的个数计算出窗口的宽和高
    super(x, y, width,[row * 32 + 32,maxh].min, type)
    @item_max = commands.size
    @commands = commands
    @row = row
    @width_txt = (width-32)/column
    @column_max = column
    @type = type
    @align = align
    self.contents = Bitmap.new(width-32, row * 32)
    refresh
    self.index = index
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    color = @type == 6 ? back_color : normal_color
    for i in 0...@item_max
      draw_item(i, color)
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
    refresh
    update_cursor_rect if @type !=0
  end
  #--------------------------------------------------------------------------
  # ● 项目无效化
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  #--------------------------------------------------------------------------
  # ● 项目有效化
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def able_item(index)
    draw_item(index, normal_color)
  end
  #--------------------------------------------------------------------------
  # ● 更改项目
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def change_item(index,item)
    @commands[index]=item
  end
end